package org.kabeja.parser.entities;

import org.kabeja.dxf.entity.DXFEntity;
import org.kabeja.dxf.entity.DXFInsert;
import org.kabeja.parser.DXFValue;

/**
 * @author shutao
 * @since 2022/4/25 11:31
 */
public class DXFInsertHandler extends AbstractEntityHandler {
    public static final int SCALE_X = 41;
    public static final int SCALE_Y = 42;
    public static final int SCALE_Z = 43;
    public static final int ROTATE = 50;
    public static final int COLUMN_COUNT = 70;
    public static final int ROW_COUNT = 71;
    public static final int COLUMN_SPACING = 44;
    public static final int ROW_SPACING = 45;
    public static final int BLOCK_NAME = 2;
    private DXFInsert insert;

    public DXFInsertHandler() {
    }

    @Override
    public void endDXFEntity() {
    }

    @Override
    public DXFEntity getDXFEntity() {
        return this.insert;
    }

    @Override
    public String getDXFEntityName() {
        return "INSERT";
    }

    @Override
    public boolean isFollowSequence() {
        return false;
    }

    @Override
    public void parseGroup(int var1, DXFValue var2) {
        switch(var1) {
            case 2:
                this.insert.setBlockID(var2.getValue());
                break;
            case 10:
                this.insert.getPoint().setX(var2.getDoubleValue());
                break;
            case 20:
                this.insert.getPoint().setY(var2.getDoubleValue());
                break;
            case 30:
                this.insert.getPoint().setZ(var2.getDoubleValue());
                break;
            case 41:
                this.insert.setScaleX(var2.getDoubleValue());
                break;
            case 42:
                this.insert.setScaleY(var2.getDoubleValue());
                break;
            case 43:
                this.insert.setScaleZ(var2.getDoubleValue());
                break;
            case 44:
                this.insert.setColumnSpacing(var2.getDoubleValue());
                break;
            case 45:
                this.insert.setRowSpacing(var2.getDoubleValue());
                break;
            case 50:
                this.insert.setRotate(var2.getDoubleValue());
                break;
            case 70:
                this.insert.setColumns(var2.getIntegerValue());
                break;
            case 71:
                this.insert.setRows(var2.getIntegerValue());
                break;
            default:
                super.parseCommonProperty(var1, var2, this.insert);
        }

    }

    @Override
    public void parseObject(int var1, DXFValue var2, int type) {
        super.parseObjectProperty(var1, var2, type, this.insert);
    }

    @Override
    public void startDXFEntity() {
        this.insert = new DXFInsert();
    }
}
